#!/usr/bin/env python2.6

from sys import exit
from optparse import OptionParser
from magenta import *

if __name__ == '__main__':
	Parser = OptionParser (prog='magenta', usage='usage: python2.6 -m %prog.__main__ [options]', version='%prog ' + __version__)
	Parser.add_option ('-i', '--infile', action='store', default=None, metavar='FILE', help="read the rules from FILE (or STDIN if empty or '-')")
	Parser.add_option ('-o', '--outfile', action='store', default=None, metavar='FILE', help="write generated commands to FILE (or STDOUT if empty or '-')")
#	Parser.add_option ('-v', '--verbose', action='store_true', default=False, help="print more")
	Options, Args = Parser.parse_args ()

	try:
		Rules = Factory (Options.infile)
	except (mTokenError, mCheckError) as X:
		print X
		exit (1)

	print Rules.render ()
